package com.amado.easyui2.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.amado.easyui2.dao.ExportCarDao;
import com.amado.easyui2.domain.CoachCarEntity;

public class ExportCarDaoImpl implements ExportCarDao {

	@Override
	public List<CoachCarEntity> listAll() {
		Connection conn = JDBC.getConn();
		PreparedStatement ps = null;
		ResultSet rs = null;
		String sql = "SELECT * FROM t_coach_car";
		List<CoachCarEntity> list = new ArrayList<CoachCarEntity>();
		try {
			ps = conn.prepareStatement(sql);
			rs = ps.executeQuery();
			while (rs.next()) {
				int i = 1;
				Long id = rs.getLong("ID");
				String bhAbbreviate = rs.getString("BH_ABBREVIATE");
				String learnCardNumber = rs.getString("LEARN_CARD_NUMBER");
				String oldLearnCardNumber = rs.getString("OLD_LEARN_CARD_NUMBER");
				String carColoc = rs.getString("CAR_COLOC");
				String carrriageNumber = rs.getString("CARRRIAGE_NUMBER");
				String engineNumber = rs.getString("ENGINE_NUMBER");
				String trainingModel = rs.getString("TRAINING_MODEL");
				String paraphraseWay = rs.getString("PARAPHRASE_WAY");
				String indexNumberNumber = rs.getString("INDEX_NUMBER_NUMBER");
				String bodyColorCar = rs.getString("BODY_COLOR_CAR");
				String automobileBrand = rs.getString("AUTOMOBILE_BRAND");
				String carType = rs.getString("CAR_TYPE");
				Date registerDay = rs.getTimestamp("REGISTER_DAY");
				Date comeintoserviceDay = rs.getTimestamp("COMEINTOSERVICE_DAY");
				Date yearCarefulTime = rs.getTimestamp("YEAR_CAREFUL_TIME");
				String yearCarefulState = rs.getString("YEAR_CAREFUL_STATE");
				String deleteLogo = rs.getString("DELETE_LOGO");
				Date createTime=rs.getTimestamp("CREATE_TIME");
				Date updateTime=rs.getTimestamp("UPDATE_TIME");
				String createName=rs.getString("CREATE_NAME");
				String updateName=rs.getString("UPDATE_NAME");
				
				CoachCarEntity coachCarEntity = new CoachCarEntity();
				coachCarEntity.setId(id);
				coachCarEntity.setBhAbbreviate(bhAbbreviate);
				coachCarEntity.setLearnCardNumber(learnCardNumber);
				coachCarEntity.setOldLearnCardNumber(oldLearnCardNumber);
				coachCarEntity.setCarColoc(carColoc);
				coachCarEntity.setCarrriageNumber(carrriageNumber);
				coachCarEntity.setEngineNumber(engineNumber);
				coachCarEntity.setTrainingModel(trainingModel);
				coachCarEntity.setParaphraseWay(paraphraseWay);
				coachCarEntity.setIndexNumberNumber(indexNumberNumber);
				coachCarEntity.setBodyColorCar(bodyColorCar);
				coachCarEntity.setAutomobileBrand(automobileBrand);
				coachCarEntity.setCarType(carType);
				coachCarEntity.setRegisterDay(registerDay);
				coachCarEntity.setComeintoserviceDay(comeintoserviceDay);
				coachCarEntity.setYearCarefulTime(yearCarefulTime);
				coachCarEntity.setYearCarefulState(yearCarefulState);
				coachCarEntity.setDeleteLogo(deleteLogo);
				coachCarEntity.setCreateName(createName);
				coachCarEntity.setCreateTime(createTime);
				coachCarEntity.setUpdateName(updateName);
				coachCarEntity.setUpdateTime(updateTime);
				list.add(coachCarEntity);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			JDBC.close(rs, ps, conn);
		}
		return list;
	}

}
